package model.dao;

import java.util.Date;
import java.util.List;

import model.entity.Consulta;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;


public class ConsultaDAO extends BaseDAO {

	public ConsultaDAO(){
		super(Consulta.class);
	}
	
	@SuppressWarnings("unchecked")
	public List<Consulta> findByPacienteData(String paciente, Date data) {
		Criteria criteria = this.createCriteria();

		if (paciente != null) {
			Criteria crit = criteria.createCriteria("paciente");
			crit.add(Restrictions.like("nome", paciente));
		}
		if (data != null) {
			criteria.add(Restrictions.eq("data", data));
		}
		return (List<Consulta>) criteria.list();

	}

}
